﻿#include <stdio.h>
#include "source/ff.h"

static FATFS disk1_fs;			// 针对disk1.vhd
static FATFS disk2_fs;			// 针对disk2.vhd

int main()
{
	// 挂载文件系统
	FRESULT res = f_mount(&disk1_fs, "0:", 1);
	if (res != FR_OK) {
		printf("mount disk1 failed.");
		return -1;
	}

	// 挂载文件系统
	res = f_mount(&disk2_fs, "1:", 1);
	if (res != FR_OK) {
		printf("mount disk2 failed.");
		return -1;
	}
	
	// 打开文件
	FIL file;
	res = f_open(&file, "0:/write2.bin", FA_WRITE | FA_CREATE_ALWAYS);
	if (res != FR_OK) {
		printf("open file error.\n");
		return -1;
	}

	static UINT16 write_buf[1024];
	for (int i = 0; i < 1024; i++) {
		write_buf[i] = i;
	}

	UINT write_size;
	f_write(&file, write_buf, sizeof(write_buf), &write_size);

	f_close(&file);

	printf("Hello, world.\n");
    return 0;
}
